﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;
using BrokerBase.Lib.Person;

namespace BrokerBase.Lib.Product.RateFactorConverter
{
    public class SexConverter:AbstractRateFactorConverter
    {
        private static readonly string[] alias = new string[] { "性别", "男女" };
        public override string[] Alias
        {
            get { return alias; }
        }


        public override bool IsToPropertiesEnable { get { return false; } }

        public override void ToProperties()
        {
            throw new NotImplementedException();
        }

        public override bool IsPolicySelectedEnable { get { return false; } }

        public override void ToPolicySelected(IPolicy policy, string item)
        {
            throw new NotImplementedException();
        }

        public override string GetItemByPolicy(IPolicy policy)
        {
            string[] s=Owner.GroupItems;

            policy.SetSettingLock(Owner.Name, true);

            //string value = policy.GetSelectedRateFactorItem(Owner.Name, Owner.Axis);

            //if (!string.IsNullOrEmpty(value))
            //    return value;

            SexType sex = policy.Target == Policy.PolicyTarget.Insurant ? policy.Owner.InsurantSex : policy.Owner.HolderSex;

            if (sex == SexType.Male)
                return s.FirstOrDefault(p => p == "男" || p == "Male" || p=="男性");
            else
                return s.FirstOrDefault(p => p == "女" || p == "Fmale" || p=="女性");
        }

        public override bool IsFixedProperty
        {
            get
            {
                return true;
            }
        }
    }
}
